﻿// This code is released under the BSD license.
namespace PugLib.UnitTest
{
    #region

    using System.Linq;
    using Extensions.Collections;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using TestCollateral;

    #endregion

    /// <summary>
    ///This is a test class for BetterLinqTest and is intended
    ///to contain all BetterLinqTest Unit Tests
    ///</summary>
    [TestClass]
    public class BetterLinqTest
    {
        [TestMethod]
        public void BetterLinqExtensions()
        {
            Person[] values = new[]
                                  {
                                      new Person {FirstName = "Bob", LastName = "Smith"},
                                      new Person {FirstName = "Don", LastName = "Allen"},
                                      new Person {FirstName = "Bob", LastName = "Sacamano"},
                                      new Person {FirstName = "Chris", LastName = "Smith"},
                                      new Person {FirstName = "George", LastName = "Allen"}
                                  };

            Assert.AreEqual(values.Distinct(person => person.LastName).Count(), 3);

            Assert.AreEqual(values.Distinct(person => person.FirstName).Count(), 4);

            Assert.IsTrue(values.Contains("Smith", person => person.LastName));

            Assert.IsFalse(values.Contains("Nixon", person => person.LastName));
        }
    }
}